<?php include "../public/header.php";?>
<?php include "../public/header_public.php";?>
<link rel='stylesheet' href='/static/admin/css/home.css'>
<style>
    .xm-label-block{border: unset!important;}
    .xm-label-block span{font-size: 18px!important;}
    .xm-icon-close{display: none!important;}
    .leftengin .caitong .caibox:hover{background: #f6f6f6 !important;}
</style>
<body id="homePage">
<div id="homeBox">
    <div class="minbox" style="margin-bottom: 10px;padding-top: 10px;height: 40px;">
        <div id="chanid" class="xmselect_div" style="width: 300px;height: 40px;margin-left: 20px"></div>
    </div>
    <div class="leftengin">
        <div class="caitong">
            <div class="caibox"><div class="tit">本月到账资金</div><div class="con colorlan" id="account_shou"></div></div>
            <div class="caibox"><div class="tit">本月支出资金</div><div class="con colorlan" id="account_zhi"></div></div>
            <div class="caibox"><div class="tit">本月开票（价税合计）</div><div class="con colorlan" id="piao_kai"></div></div>
            <div class="caibox"><div class="tit">本月收票（价税合计）</div><div class="con colorlan" id="piao_shou"></div></div>
        </div>
        <div class="clear"></div>
        <div class="tabbox float-l">
            <div class="mintab">
                <div class="tits"><b>待支付的单据</b> <span class="nums" id="daizhinum">（0）</span></div>
            </div>
            <div class="tablist" id="daizhi">
                <div class="hang hangxian">
                    <div class="cs cs1">来源</div>
                    <div class="cs cs2">金额(元)</div>
                    <div class="cs cs3">付款对象</div>
                    <div class="cs cs4">发起时间</div>
                    <div class="clear"></div>
                </div>
                <div class="conss"><div class="nodata"><img src="/static/admin/images/welnodata.png" alt=""><div>暂无数据</div></div></div>
            </div>
        </div>
        <div class="tabbox float-r" style="width: calc(50% - 25px);">
            <div class="mintab">
                <div class="tits"><b>待开具的保函</b> <span class="nums" id="daibaonum">（0）</span></div>
            </div>
            <div class="tablist" id="daibao">
                <div class="hang hangxian">
                    <div class="cs cs1">流程单号</div>
                    <div class="cs cs2">保函类别</div>
                    <div class="cs cs3">保证金类型</div>
                    <div class="cs cs4">保函金额(元)</div>
                    <div class="cs cs5">截止时间</div>
                    <div class="clear"></div>
                </div>
                <div class="conss"><div class="nodata"><img src="/static/admin/images/welnodata.png" alt=""><div>暂无数据</div></div></div>
            </div>
        </div>

        <div class="tabbox float-l">
            <div class="mintab">
                <div class="tits"><b>待处理的开票</b> <span class="nums" id="daipiaonum">（0）</span></div>
            </div>
            <div class="tablist" id="daipiao">
                <div class="hang hangxian">
                    <div class="cs cs1">发票类型</div>
                    <div class="cs cs2">开具金额(元)</div>
                    <div class="cs cs3">项目名称</div>
                    <div class="cs cs4">发起时间</div>
                    <div class="clear"></div>
                </div>
                <div class="conss"><div class="nodata"><img src="/static/admin/images/welnodata.png" alt=""><div>暂无数据</div></div></div>
            </div>
        </div>
        <div class="tabbox float-r" style="width: calc(50% - 25px);">
            <div class="mintab">
                <div class="tits"><b>待认领的项目来款</b> <span class="nums" id="dairennum">（0）</span></div>
            </div>
            <div class="tablist" id="dairen">
                <div class="hang hangxian">
                    <div class="cs cs1">收款对象</div>
                    <div class="cs cs2">到账金额(元)</div>
                    <div class="cs cs3">到账日期</div>
                    <div class="clear"></div>
                </div>
                <div class="conss"><div class="nodata"><img src="/static/admin/images/welnodata.png" alt=""><div>暂无数据</div></div></div>
            </div>
        </div>
    </div>
    <div class="rightengin" style="height: 734px">
        <div class="tits"><b>往来单位动态</b></div>
        <div class="chadt">
            <div id="checkchanid" class="layui-hide"></div>
            <input type="text" id="dongdt" readonly placeholder="请选择" autocomplete="off" class="layui-input bdate_dongdt">
        </div>
        <div class="linecon">
            <ul class="layui-timeline" id="dongList"></ul>
        </div>
    </div>

</div>
<script>
    $('.tablist').on('mouseover','.conss .hang',function () {
        $(this).addClass('colorlan');
    }).on('mouseout','.conss .hang',function () {
        $(this).removeClass('colorlan');
    });
    $('#dongList').on('mouseover','p',function () {
        $(this).addClass('colorlan');
    }).on('mouseout','p',function () {
        $(this).removeClass('colorlan');
    });

    layui.use(['form', 'layer', "laytp",'element','dropdown'], function() {
        var form = layui.form, element = layui.element;
        get_cai_chan_home();



        function get_cai_chan_home(chanid=0){
            facade.ajax({url: ask_cai_chan_home, data:{chanid:chanid}}).done(function(res){
                if (res.code === 2000) {
                    var data = res.data;
                    $("#account_shou").html(parseFormatNum(data.account_shou));
                    $("#account_zhi").html(parseFormatNum(data.account_zhi));
                    $("#piao_kai").html(parseFormatNum(data.piao_kai));
                    $("#piao_shou").html(parseFormatNum(data.piao_shou));


                    $("#checkchanid").text(res.data.is_chanid);
                    xmselect_dan('chanid', res.data.chanid, res.data.is_chanid, function (res) {
                        get_cai_chan_home(res.change[0].id)
                    })


                    var daizhi = res.data.daizhi;
                    var daizhistr = '';
                    if(daizhi.length > 0){
                        for (var key in daizhi){
                            daizhistr += '<div class="hang">';
                            daizhistr += '<div class="cs cs1 colorlan">'+daizhi[key].lai+'</div>';
                            daizhistr += '<div class="cs cs2 txtright">'+parseFormatNum(daizhi[key].money)+'</div>';
                            daizhistr += '<div class="cs cs3">'+daizhi[key].gonger+'</div>';
                            daizhistr += '<div class="cs cs4">'+daizhi[key].created_at+'</div>';
                            daizhistr += '<div class="clear"></div>';
                            daizhistr += '</div>';
                        }
                    }else{
                        daizhistr += '<div class="nodata"><img src="/static/admin/images/welnodata.png" alt=""><div>暂无数据</div></div>';
                    }
                    $("#daizhinum").html('（'+daizhi.length+'）')
                    $("#daizhi .conss").html(daizhistr);




                    var daibao = res.data.daibao;
                    var daibaostr = '';
                    if(daibao.length > 0){
                        for (var key in daibao){
                            daibaostr += '<div class="hang">';
                            daibaostr += '<div class="cs cs1">'+daibao[key].sericnum+'</div>';
                            daibaostr += '<div class="cs cs2 colorlan">'+daibao[key].hantype+'</div>';
                            daibaostr += '<div class="cs cs3">'+daibao[key].bondtype+'</div>';
                            daibaostr += '<div class="cs cs4 txtright">'+parseFormatNum(daibao[key].money)+'</div>';
                            daibaostr += '<div class="cs cs5">'+daibao[key].jiedt+'</div>';
                            daibaostr += '<div class="clear"></div>';
                            daibaostr += '</div>';
                        }
                    }else{
                        daibaostr += '<div class="nodata"><img src="/static/admin/images/welnodata.png" alt=""><div>暂无数据</div></div>';
                    }
                    $("#daibaonum").html('（'+daibao.length+'）')
                    $("#daibao .conss").html(daibaostr);



                    var daipiao = res.data.daipiao;
                    var daipiaostr = '';
                    if(daipiao.length > 0){
                        for (var key in daipiao){
                            daipiaostr += '<div class="hang">';
                            daipiaostr += '<div class="cs cs1 colorlan">'+daipiao[key].piaotype+'</div>';
                            daipiaostr += '<div class="cs cs2 txtright">'+parseFormatNum(daipiao[key].money)+'</div>';
                            daipiaostr += '<div class="cs cs3">'+daipiao[key].enginname+'</div>';
                            daipiaostr += '<div class="cs cs4">'+daipiao[key].created_at+'</div>';
                            daipiaostr += '<div class="clear"></div>';
                            daipiaostr += '</div>';
                        }
                    }else{
                        daipiaostr += '<div class="nodata"><img src="/static/admin/images/welnodata.png" alt=""><div>暂无数据</div></div>';
                    }
                    $("#daipiaonum").html('（'+daipiao.length+'）')
                    $("#daipiao .conss").html(daipiaostr);



                    var dairen = res.data.dairen;
                    var dairenstr = '';
                    if(dairen.length > 0){
                        for (var key in dairen){
                            dairenstr += '<div class="hang">';
                            dairenstr += '<div class="cs cs1">'+dairen[key].faer+'</div>';
                            dairenstr += '<div class="cs cs2 colorlan txtright">'+dairen[key].money+'</div>';
                            dairenstr += '<div class="cs cs3">'+dairen[key].dt+'</div>';
                            dairenstr += '<div class="clear"></div>';
                            dairenstr += '</div>';
                        }
                    }else{
                        dairenstr += '<div class="nodata"><img src="/static/admin/images/welnodata.png" alt=""><div>暂无数据</div></div>';
                    }
                    $("#dairennum").html('（'+dairen.length+'）')
                    $("#dairen .conss").html(dairenstr);

                    get_cai_dong_home();

                    render_from();
                }
            });
        }



        $('.bdate_dongdt').datetimepicker({
            language: 'zh-CN',
            format: 'yyyy-mm-dd',
            minView: "month",
            initialDate: new Date(),
            autoclose: true,
            todayBtn: true,
        }) .on('changeDate',function (e) {
            get_cai_dong_home($("#dongdt").val())
        });

        function get_cai_dong_home(dt=''){
            var chanid = $("#checkchanid").text();
            facade.ajax({url: ask_cai_dong_home, data:{chanid:chanid, dt:dt}}).done(function(res){
                if (res.code === 2000) {
                    var data = res.data;
                    var list = res.data.data;
                    $("#dongdt").val(data.isdt);

                    var str = '';
                    if(list.length > 0){
                        for (var key in list){
                            str += '<li class="layui-timeline-item">';
                            str += '<i class="layui-icon layui-timeline-axis">&#xe643;</i>';
                            str += '<div class="layui-timeline-content layui-text">';
                            str += '<div class="layui-timeline-title" style="font-size: 14px!important;">';
                            str += list[key].faer;
                            str += '</div>';
                            str += '<p>'+list[key].type_name+'：<span class="colorlan">'+parseFormatNum(list[key].money)+'</span></p>';
                            str += '</div>';
                            str += '</li>';
                        }
                    }else{
                        str += '<div class="nodata"><img src="/static/admin/images/welnodata.png" alt=""><div>暂无数据</div></div>';
                    }



                    $("#dongList").html(str);
                    render_from();
                }
            });
        }


    });
</script>
</body>
</html>
